<extend name="Base/common" />
<block name="Content">
    <div class="am-cf am-padding-top">
        <div class="am-fl am-cf">
            <i class="am-icon-file"></i>
            <strong class="am-text-primary am-text-lg">小哥管理</strong>
        </div>
        <hr data-am-widget="divider" class="am-divider am-divider-default" />
    </div>
   
        <div class="am-u-sm-12 am-u-md-6" style="padding:0px">
            <div class="am-btn-toolbar">
                <div class="am-btn-group am-btn-group-xs">
                    <a class="am-btn am-btn-success" href="{:U('editAction')}">
                    	<span class="am-icon-plus"></span>&nbsp;新增
                    </a>
                </div>
            </div>
        </div>
    <div class="am-fr am-padding-right am-u-md-3">
		<a class="am-margin-top-sm am-btn am-btn-primary am-btn-xs am-fr" id="high-class"> 
			<i class="am-icon-search"></i>&nbsp;&nbsp;高级查询
		</a>
	</div>
  
    <table class="am-table am-table-striped am-table-hover table-main">
        <thead>
            <tr>
                <th class="table-type am-text-left" style="width:8%">
                    账号
                </th>
                <th class="table-title am-text-left" style="width:8%">
                    姓名
                </th>
                <th class="table-title am-text-left" style="width:12%">
                   接单数(单)/平均工时(小时)
                </th>
                <th class="table-title am-text-left" style="width:10%">
                   所在站点
                </th>
                <th class="table-title am-text-left" style="width:6%">
                   账户余额
                </th>
                <th class="table-title am-text-left" style="width:10%">
                   自有成员
                </th>
                <th class="table-set am-text-left" style="width:40%">
                    操作
                </th>
            </tr>
        </thead>
        <tbody>
            <notempty name="list">
                <foreach name="list" item="worker">
                    <tr>
                        <td>
                            {$worker.account}
                        </td>
                        <td>
                            {$worker.name}
                        </td>
                        <td>
                            {$worker.orders_sum}/{$worker.avg_hour}
                        </td>
                        <td>
                            {$worker.site_name}
                        </td>
                        <td>
                            {$worker.balance}
                        </td>
                        <td>
                            <eq name="worker.member_type" value="1">是<else/>否</eq>
                        </td>
                        <td>
                            <div class="am-btn-toolbar">
                                <div class="am-btn-group am-btn-group-xs">
                                    <a class="am-btn am-btn-default am-btn-xs am-text-secondary" 
                                    	href="{:U('editAction?worker_id='.$worker['worker_id'])}">
                                    	<span class="am-icon-pencil-square-o"></span>编辑
                                    </a>
                                    <a class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only ajax-get confirm" 
                                    	href="{:U('del?worker_id='.$worker['worker_id'])}">
                                    	<span class="am-icon-trash-o"></span>删除
                                    </a>
                                    <a class="am-btn am-btn-default am-btn-xs am-text-warning custom-cash" 
                                    	wid="{$worker['worker_id']}">
                                    	<span class="am-icon-money"></span>提现/充值
                                    </a>
                                    <a class="am-btn am-btn-default am-btn-xs am-text-primary" 
                                    	href="{:U('cashFlow?worker_id='.$worker['worker_id'])}">
                                    	<span class="am-icon-money"></span>资金流水
                                    </a>
                                    <a class="am-btn am-btn-default am-btn-xs am-text-secondary" 
                                    	href="{:U('Orders/index', array('w_contact'=>$worker['account'],'status'=>'0'))}">
                                    	<span class="am-icon-pencil-square-o"></span>全部订单
                                    </a>
                                    <a class="am-btn am-btn-default am-btn-xs am-text-secondary" 
                                    	href="{:U('evaluation?worker_id='.$worker['worker_id'])}">
                                    	<span class="am-icon-pencil-square-o"></span>用户评价
                                    </a>
                                </div>
                            </div>
                        </td>
                    </tr>
                </foreach>
                <else/>
                <td colspan="9" class="text-center">
                    aOh! 暂时还没有内容!
                </td>
            </notempty>
        </tbody>
    </table>
    <!-- 分页 -->
    <ul class="am-pagination am-pagination-default am-no-layout amz-social">
        {$_page}
    </ul>
    <!-- /分页 -->
    
    <include file="Worker/cashModal"/>
    <include file="Worker/searchModal"/>
</block>
<block name="style">
    <style type="text/css">
        .am-table {
            padding-left: 0px;
            margin-left: 0px
        }
    </style>
</block>
<block name="script">
<script type="text/javascript">

//弹出模态框
$("#high-class").click(function(){
	$('#worker-search').modal({
		relatedTarget: this,
        closeViaDimmer: 0,
    });
})

//弹出模态框
$(".custom-cash").click(function(){
	
	var workerID = $(this).attr('wid');
	var target = Think.U('Worker/ajax_info');
	$.post(target, {'worker_id':workerID}, function(data){
		
		if(data.status == 1){
			var info = data.info;
			var memberType = data.member_type == '1' ? '自有团队' : '闲散小哥';
			
			$("#name").html(info.name);
			$("#telphone").html(info.account);
			$("#balance").html(info.balance);
			$("#member_type").html(memberType);
			$("#account").val(info.account);
			$("#worker_id").val(info.worker_id);
			
			if(info.balance < 1){
				$("#op_type option[value='1']").remove();
			}
			
			$('#cash-modal').modal({
				relatedTarget: this,
		        closeViaDimmer: 0,
		    });
			
		}else{
			alert('参数错误，请刷新后重新');
		}
	});
	
})


</script>
</block>
